import glRequest from './index'
import type { IUserInfo, IData, RootObject,Data } from '@/network/typing'
import type { MenuType,MenuChildren,MenuData } from '@/network/menuType'

// 登录相关接口
enum LOGIN_URL {
  LOGIN = '/login',
  USER = '/users', // 用法: /users/1
  MENUS = '/role', // 用法： /role/1/menu
}

export function accountLogin( data: IUserInfo ){
  return glRequest.post<RootObject<IData>>({
    url:LOGIN_URL.LOGIN,
    data
  })
}


export function requestUser( id:number ){
  return glRequest.get<RootObject<Data>>({
    url:LOGIN_URL.USER + `/${id}`,
  })
}

export function requestUserMenu( id:number ){
  return glRequest.get<MenuType<MenuData<MenuChildren>>>({
    url:LOGIN_URL.MENUS + `/${id}/menu`,
  })
}
